﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Zaggit.UI
{
    public partial class ZaggitSettings : Form
    {
        public ZaggitSettings()
        {
            InitializeComponent();
        }

        private void Cancel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.Close();
        }

        private void Save_Click(object sender, EventArgs e)
        {
            var s = new Properties.Settings();
            var port = int.Parse(Port.Text);
            if (port >= 1000 && port <= 9999)
            {
                s.Port = port;
                s.ShowBalloon = NotifyOnNewMessages.Checked;
                s.ChangeIcon = ChangeIconOnNewMessages.Checked;
                s.Save();

                MessageBox.Show("Your settings have been saved.  Please restart Zaggit.", "Settings saved.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                return;
            }

            MessageBox.Show("The port to use should be a number between 1000 and 9999.", "Port is incorrect", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        private void ZaggitSettings_Load(object sender, EventArgs e)
        {
            var s = new Properties.Settings();
            Port.Text = s.Port.ToString();
            NotifyOnNewMessages.Checked = s.ShowBalloon;
            ChangeIconOnNewMessages.Checked = s.ChangeIcon;
        }
    }
}
